package com.ghao.douban.controller;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ghao.douban.Entity.MovieInfo;
import com.ghao.douban.mapper.MovieInfoMapper;
import com.ghao.douban.services.MovieInfoService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletRequest;
import java.util.HashMap;
import java.util.List;

/**
 * @author Ghao
 * @date 2021/7/19 16:04
 */
@Controller
@RequestMapping("movieInfo")
public class MovieInfoController {

    @Autowired
    private MovieInfoMapper movieInfoMapper;

    @Autowired
    private MovieInfoService movieInfoService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("getMovieInfo")
    @ResponseBody
    public List<MovieInfo> getMovieInfo(){
        List<MovieInfo> movieInfos = movieInfoMapper.selectList(null);
        return movieInfos;
    }

    @GetMapping("test")
    public String test(Page<MovieInfo> page, Model model){
        List<MovieInfo> movieInfoList = movieInfoService.selectMovieByPage(page);
        model.addAttribute("movieInfoList", movieInfoList);
        return "DoubanMovie";
    }
}
